package com.qys.livesMall.anchor.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qys.livesMall.anchor.mapper.AnchorLivesSessionMapper;
import com.qys.livesMall.anchor.model.dto.lives.sys.QueryLiveRoomDTO;
import com.qys.livesMall.anchor.model.entity.AnchorLivesSession;
import com.qys.livesMall.anchor.service.AnchorLivesSessionService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 直播场次表 服务实现类
 * </p>
 *
 * @author wzy
 * @since 2023-06-26
 */
@Service
public class AnchorLivesSessionServiceImpl extends ServiceImpl<AnchorLivesSessionMapper, AnchorLivesSession> implements AnchorLivesSessionService {


    @Override
    public AnchorLivesSession getIsStarted(Long livesRoomId) {
        return getOne(Wrappers.<AnchorLivesSession>lambdaQuery()
                .eq(AnchorLivesSession::getLivesRoomId, livesRoomId)
                .eq(AnchorLivesSession::getLivesStatus, 2)//开播中
        );
    }

    @Override
    public Page<AnchorLivesSession> pageAllRoom(QueryLiveRoomDTO dto) {
        return baseMapper.selectAllRoomPage(new Page<>(dto.getPageNum(), dto.getPageSize()), dto);
    }

    @Override
    public String randomMessage(int type) {
        return baseMapper.randomMessage(type);
    }
}
